package i2.application.checklist.entities;

import static javax.persistence.GenerationType.AUTO;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;


@Entity
@Table(name = "livrable_champ_value")
public class LivrableChampValue implements Serializable {

	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy = AUTO)
	@Column(name = "id", unique = true, nullable = false)
	private int id;
	
	@Column(name = "value", length = 45)
	private String value;
	
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="livrable_champ_id", nullable = false)
	private LivrableChamp livrableChamp;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="livrable_id", nullable = false)
	private Livrable livrable;
	
	public LivrableChampValue() {
	}
	
	public LivrableChampValue(int id) {
		this.id = id;
	}
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}	

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public LivrableChamp getLivrableChamp() {
		return livrableChamp;
	}

	public void setLivrableChamp(LivrableChamp livrableChamp) {
		this.livrableChamp = livrableChamp;
	}

	public Livrable getLivrable() {
		return livrable;
	}

	public void setLivrable(Livrable livrable) {
		this.livrable = livrable;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

    @Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		LivrableChampValue other = (LivrableChampValue) obj;
		if (id != other.id) {
			return false;
		}
		return true;
	}
    
    @Override
	public String toString() {
		return "LivrableChampValue [id=" + id + ", value=" + value+ "]";
	}

}
